# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=gdb
_target=avr

pkgbase=mingw-w64-${_target}-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_target}-${_realname}
pkgver=9.2
pkgrel=3
pkgdesc='The GNU Debugger for AVR (mingw-w64)'
arch=('any')
license=('GPL')
url='https://www.gnu.org/software/gdb/'
groups=("${MINGW_PACKAGE_PREFIX}-${_target}-toolchain")
source=(https://ftp.gnu.org/gnu/${_realname}/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=(
    '360cd7ae79b776988e89d8f9a01c985d0b1fa21c767a4295e5f88cb49175c555'
    'SKIP'
)
validpgpkeys=('F40ADB902B24264AA42E50BF92EDB04BFF325CF3') # Joel Brobecker

prepare() {
    cd ${srcdir}/${_realname}-${pkgver}

    mkdir ${_realname}-build
}

build() {
    cd ${srcdir}/${_realname}-${pkgver}/${_realname}-build

    ../configure \
        --build=${MINGW_CHOST} \
        --prefix=${MINGW_PREFIX} \
        --target=${_target} \
        --disable-nls \
        --disable-debug \
        --disable-dependency-tracking \
        --disable-binutils \
        --disable-libssp \
        --disable-install-libbfd \
        --disable-install-libiberty \
        --with-system-readline
    make
}

package() {
    cd ${srcdir}/${_realname}-${pkgver}/${_realname}-build

    make DESTDIR="$pkgdir" install-gdb

    cd ${pkgdir}${MINGW_PREFIX}

    # Remove files that conflict with native gdb
    rm -rf include share/gdb share/info
}
